/*********************************************************************
 *
 *  elksip - a multi-platform Sip Phone Server
 *
 *  file: unit_test.c
 *
 *  Copyright 2011-2013 Elksip.
 *
 ********************************************************************/

#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>

#include"sip_msg.h"

int main(int argc, char* argv[])
{
    if(argc<2)
    {
        printf("need filename\n");
        return -1;
    }
    FILE *fd = fopen(argv[1], "r");
    if(fd==NULL)
    {
        printf("open file error\n");
        return -2;
    }
    char buf[1300] = {0};
    int size = fread(&buf, 1,  sizeof(buf), fd);
    printf("size=%d\n", size);
    printf(buf);
    fclose(fd);


    Sip_Message msg;    
    Sip_Message_init(&msg);
    int len=1300;
    char strMsg[1300];
    int ret = parseMsg(&buf, &msg);

    
    Sip_Message2str(&msg, strMsg, &len);

    printf("%s\n", strMsg);
    

    return 0;
}
